package day3;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class ForAndBreak2 {
    public static void main(String[] args) {

        //5门课求平均分
        String name;
        Scanner in = new Scanner(System.in);
        System.out.println("请输入姓名：");
        name = in.next();

        double total = 0;
        int i = 1;
        for (; i <= 5; i++) {
            System.out.print("请输入成绩：");
            double s = in.nextDouble();
            if (s < 0) {
                System.out.println("录入错误，退出程序");

                break;
            }
            total += s;
        }
        if (i > 5) {
            double avg = total / 5;
            System.out.println(name + "的平均成绩为：" + avg);
        }


    }
}


